package com.jk.mapper;

import com.jk.model.ProductBean;
import com.jk.model.UserBean;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Mapper
public interface SLFMapper {
    @Select("select * from t_user where userAccount=#{value} ")
    UserBean findUserInfoByAccount(String userAccount);

    @Select("select tpr.*,tpy.typeName from t_product tpr\n" +
            " LEFT JOIN t_product_type tpy ON tpr.typeId=tpy.typeId\n" +
            "where productState = 1 ORDER BY tpr.id  limit 0,4")
    List<Map> findProductState();

    @Select("select tpr.*,tpy.typeName from t_product tpr\n" +
            " LEFT JOIN t_product_type tpy ON tpr.typeId=tpy.typeId\n" +
            "where tpr.id = #{value}")
    List<Map> findParticularsApp(Integer id);

    @Select("select tu.*from t_user tu where tu.id = #{value}")
    List<Map> findPersonalCenter(Integer userId);

    @Select("select tp.*,ts.stockNumber from t_product tp \n" +
            "        left join t_stock ts on tp.productStockId=ts.id\n" +
            "         where tp.id = #{value}")
    ProductBean findShopApp(Integer productId);






    @Select("select tpr.*,tpy.typeName from t_product tpr\n" +
            " LEFT JOIN t_product_type tpy ON tpr.typeId=tpy.typeId\n" +
            "where productState = 1 ORDER BY tpr.id desc limit 0,6")
    List<Map> findTheLatest();


    @Insert("insert into t_user(userAccount,userPassword,userSex,userAge,userPhone) \n" +
            "       VALUES(#{userAccount},#{userPassword},1,#{userAge},#{userPhone})")
    void saveFeg(UserBean userBean);

    List<Map> findClassify(HashMap hashMap);
}
